package top.zhan.memento;

import com.sun.source.doctree.AttributeTree;

/**
 * @author Zhan
 * @date 2022/10/9 20:03
 */
public class RoleOriginator {

    /**
     * 生命力，会下降
     */
    private int live = 100;

    /**
     * 攻击力，会上涨
     */
    private int attack = 50;

    public int getLive() {
        return live;
    }
    public void setLive(int live) {
        this.live = live;
    }
    public int getAttack() {
        return attack;
    }
    public void setAttack(int attack) {
        this.attack = attack;
    }

    public void display(){
        System.out.println("开始=============");
        System.out.println("生命力：" + live);
        System.out.println("攻击力：" + attack);
        System.out.println("结束=============");
    }

    public void fight(){
        //攻击力会上涨
        this.attack = attack + 2;
        //生命力会下降
        this.live = live - 2;
    }

    /**
     * 保存快照
     * @return
     */
    public RoleStateMemento roleSave(){
        return new RoleStateMemento(live, attack);
    }

    public void recoveryState(RoleStateMemento roleStateMemento){
        this.attack = roleStateMemento.getAttack();
        this.live = roleStateMemento.getLive();
    }
}
